package com.bcx.crm.controller;

import com.bcx.crm.entity.Template;
import com.bcx.crm.mapper.templateTestMapper.SelectTemplateMapper;
import com.bcx.crm.plat.core.utils.SpringContextHolder;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.util.*;

/**
 * Created by ys on 2017/12/30.
 */
@Controller
@RequestMapping("/template")
public class DmsTemplate extends HttpServlet{
    public static final Map<String,Object> map = new HashMap<>();
    @RequestMapping(path = "/path1",method = RequestMethod.GET)
    public String getResult(HttpServletRequest httpServletRequest){
        ModelAndView modelAndView = new ModelAndView();
        Set<Object> objects = new HashSet<>();
        objects.add("objects2");
        modelAndView.addObject("objects",objects);
        String s="index";
        HttpSession session3 = httpServletRequest.getSession();
        int count =(Integer) session3.getServletContext().getAttribute("Count");
        if (count==0){
            throw new NullPointerException("");
        }
        return "public/"+s;
    }
    @RequestMapping("/getTemplateList")
    @ResponseBody
    public List<Template> getTemplateList(){
        SelectTemplateMapper selectTemplateMapper = SpringContextHolder.getBean(SelectTemplateMapper.class);
        return selectTemplateMapper.getList1(map);
    }
}
